package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;

/**
 * User: KuznetsovD
 * Date: 25.10.11
 * Time: 16:14
 */

public enum GeoserverAttribute implements GISAccountProperty {
    UseProvider(GisParameter.use_map_provider, MapProviderType.geoserver, GISFieldType.BOOLEAN, "false", true, 0L, true),
    GeoserverUrl(GisParameter.base_url, MapProviderType.geoserver, TEXT, "http://10.11.13.31:8080/geoserver/gwc/demo/ingit2", false, 1L, true),
    GeoserverLayers(GisParameter.layers, MapProviderType.geoserver, TEXT, "ingit", false, 2L, true),
    GeoserverFormat(GisParameter.format, MapProviderType.geoserver, TEXT, "image/png", false, 3L, true),
    GeoserverProjection(GisParameter.projection, MapProviderType.geoserver, TEXT, "EPSG:900913", false, 4L, true),
    GeoserverUseCustomGeoAddressForm(GisParameter.use_custom_geo_address_form, MapProviderType.geoserver, BOOLEAN, "false", true, 5L, true),
    GeoserverUseShortestRoute(GisParameter.use_shortest_route, MapProviderType.geoserver, GISFieldType.BOOLEAN, "true", false, 6L, true),
    GeoserverEnableLog(GisParameter.enableLogging, MapProviderType.geoserver, GISFieldType.BOOLEAN, "false", false, 7L, true),
    GeoserverUseMultiplePointsRouting(GisParameter.useMultiplePointsRouting, MapProviderType.geoserver, GISFieldType.BOOLEAN, "false", false, 8L, true);

    private String name;
    private String label;
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;
    private String tab = "GIS";

    public boolean isImportant() {
        return important;
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    private GeoserverAttribute(String name, String label, GISFieldType type, String defaultValue,
                               boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private GeoserverAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                               String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return false;
    }

}
